package com.herui.iot.ui.report;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.herui.sport_care.R;
import com.herui.sport_care.data.report.EvaluatorAppQueryEvaluationReportSingleResp;
import com.herui.sport_care.data.report.ReportUser;
import com.herui.sport_care.ui.BaseSportFragment;

import org.w3c.dom.Text;

import java.util.List;

import butterknife.BindView;

/**
 * 单项报告详情
 */
public class SingleReportDetailFragment extends BaseSportFragment {

    ReportPresenter reportPresenter;

    @BindView(R.id.tv_quiescent_hr)
    TextView quiescentHr;
    @BindView(R.id.tv_quiescent_highest_low_hr)
    TextView quiescentHighestLowHr;
    @BindView(R.id.tv_recover_one_minute_hr)
    TextView recoverOneMinuteHr;
    @BindView(R.id.tv_recover_two_minute_hr)
    TextView recoverTwoMinuteHr;
    @BindView(R.id.tv_quiescent_blood_oxygen)
    TextView quiescentBloodOxygen;
    @BindView(R.id.tv_recover_blood_oxygen)
    TextView recoverBloodOxygen;
    @BindView(R.id.tv_quiescent_bp)
    TextView quiescentbp;
    @BindView(R.id.tv_recover_one_bp)
    TextView recoverOnebp;
    @BindView(R.id.tv_recover_two_bp)
    TextView recoverTwobp;
    @BindView(R.id.tv_recover_three_bp)
    TextView recoverThreebp;

    private int id;
    private String name;

    public SingleReportDetailFragment() {
        // Required empty public constructor
        reportPresenter = new ReportPresenter(reportView);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = super.onCreateView(inflater, container, savedInstanceState);
        setTitle("单项评估报告-"+name);
        return view;
    }

    @Override
    public int getLayout() {
        return R.layout.fragment_single_report_detail;
    }

    @Override
    public void initParam() {
        reportPresenter.getEvaluationReportSingle(Long.valueOf(id));
    }

    public static SingleReportDetailFragment newInstance(int id,String name) {
        SingleReportDetailFragment fragment = new SingleReportDetailFragment();
        fragment.id = id;
        fragment.name = name;
        Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }

    ReportPresenter.View reportView = new ReportPresenter.View() {
        @Override
        public void onEvaluatorAppQueryEvaluationReportSingleResp(EvaluatorAppQueryEvaluationReportSingleResp resp) {
            quiescentHr.setText(resp.getQuiescentHr()+"");
            quiescentHighestLowHr.setText("最低："+resp.getQuiescentLowestHr()+"次/分 最高："+resp.getQuiescentHighestHr()+"次/分");
            recoverOneMinuteHr.setText(resp.getRecoverOneMinuteHr()+"");
            recoverTwoMinuteHr.setText(resp.getRecoverTwoMinuteHr()+"");

            quiescentBloodOxygen.setText(resp.getQuiescentBloodOxygen()+"%");
            recoverBloodOxygen.setText(resp.getRecoverBloodOxygen()+"%");

            quiescentbp.setText(resp.getQuiescentDbp() + "/" + resp.getQuiescentSbp());
            recoverOnebp.setText(resp.getRecoverOneDbp() + "/" + resp.getRecoverOneSbp());
            recoverTwobp.setText(resp.getRecoverTwoDbp() + "/" + resp.getRecoverTwoSbp());
            recoverThreebp.setText(resp.getRecoverthreeDbp() + "/" + resp.getRecoverThreeSbp());

        }
    };


}